package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.domain.*;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 创建时间：2020-08-22-9:41 xiaotian(●'◡'●))
 * 类说明：
 * 类注解：
 */

public interface OrderDao {


    /*--------------------------------orderSetting---------------------------------------*/
    List<OrderSetting> getOrderSettingByMonth(HashMap map);

    long findCountByOrderDate(Date orderDate);

    void editNumberByOrderDate(OrderSetting orderSetting);

    void addNumberByOrderDate(OrderSetting orderSetting);


    /*--------------------------------order---------------------------------------*/
    @Select("select * from t_order where id = #{id}")  //order.html的回显数据
    Order findOrder(Integer id);

    @Delete("delete from t_order where id =#{id}")  //order.html删除
    void deleteOrder(int id);

    @Update("UPDATE t_order SET member_id=#{member_id},orderDate=#{orderDate},NAME=#{name},orderType=#{orderType},orderStatus=#{orderStatus},telphone=#{telphone} WHERE id=#{id};")
    void orderUpdate(Order order);

    @Select("SELECT * FROM t_order where id = #{id}")
    List<Order> findOrderByIdPage(int id);

    /*@Select("SELECT * FROM t_order where  NAME LIKE #{param} OR id LIKE #{param} or member_id like #{param}")
    List<Order> findOrderByPage(String param);*/

    @Insert("insert into t_order values(null,#{member_id},#{orderDate},#{name},#{orderType},#{orderStatus},#{setmeal_id},#{telphone})")
    void orderAdd(Order order);

    //order分页查询
    Page<Order> selectByCondition(String queryString);

    @Select("select * from t_checkitem")
    List<OrderCheckItem> findCheckItemAll();


    /*--------------------------------CheckGroup---------------------------------------*/

    //检查组分页查询
    Page<CheckGroup> findCheckItemPage(String queryString);

    //1.添加检查组合，同时需要设置检查组合和检查项的关联关系
    void addcheckitem(CheckGroup checkGroup);

    //2.设置检查组合和检查项的关联关系
    void setCheckGroupAndCheckItem(Map m);

    //用于修改回显
    @Select("SELECT * FROM t_checkgroup where id = #{id}")
    CheckGroup findById(Integer id);

    //新建：检查项信息回显
    List<Integer> findCheckItemIdsByCheckGroupId(Integer id);

    //根据检查组id删除中间表数据（清理原有关联关系）
    void deleteAssociation(int id);

    void edit(CheckGroup checkGroup);  //t_checkgroup删除修改

    @Delete("delete from t_checkgroup where id =#{id}")  //t_checkgroup删除
    void deleteCheckGroup(int id);

    Page findCheckItem(String queryString);  //t_checkitem查询

    @Delete("delete from t_checkitem where id = #{id}")  //t_checkitem删除
    void checkitemDelete(Integer id);

    void addCheckitem(OrderCheckItem orderCheckItem);  //t_checkitem新增

    void checkitemedit(OrderCheckItem orderCheckItem);  //t_checkitem修改

    List<CheckGroup> findCheckGroup();

    Page findSetMealPage(String queryString);

    void deleteSetmeal(Integer id);

    List<CheckGroup> findCheckItemPage2();

    void addSetmeal(Setmeal setmeal);

    void setSetmealAndCheckGroup(Map<String, Integer> map);
}
